<?php

    /**
     * This file is part of the Intelligencer package.
     * For the full copyright and license, please view the LICENSE
     * file that was distributed with this source code.
     * 
     * @author      drapeko <roman.drapeko@gmail.com>
     * @copyright   Roman Drapeko <roman.drapeko@gmail.com>, 2009 - present
     */

    /**
     * Local cache is object that is alive only for the script execution time. Very convenient to use
     * in case of doing the particular thing only once during the execution time.
     * 
     * @author drapeko
     */
    class itLocalCache extends itCache {
        
        protected $cache = array();
        
        /**
         * (non-PHPdoc)
         * @see Intelligencer/LibUtil/Cache/itCache#set($key, $value)
         */
        public function set($key, $val) {
            $this->cache[$key] = $val;
        }
        
        /**
         * (non-PHPdoc)
         * @see Intelligencer/LibUtil/Cache/itCache#get($key)
         */
        public function get($key) {
            if (array_key_exists($key, $this->cache)) {
                $val = $this->cache[$key];
                return $val;
            }
            
            return null;
        }
        
        /**
         * (non-PHPdoc)
         * @see Intelligencer/LibUtil/Cache/itCache#del($key)
         */
        public function del($key) {
            if (array_key_exists($key, $this->cache)) {
                unset($this->cache[$key]);
            }
        }
        
        /**
         * (non-PHPdoc)
         * @see Intelligencer/LibUtil/Cache/itCache#clear()
         */
        public function clear() {
            $this->cache = array();
        }

    }
    
?>